﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TpAgentCore.Base;
using TpTools;
using TpLogger;

namespace TpAgent
{
	public class Program
	{
		[STAThread]
		static void Main(string[] args)
		{
			Logger tpLog = new Logger();
			tpLog.Add("Start TpAgent");
			tpLog.SaveToDisk();
            try {
                Agent myCore = new Agent();
                if (args == null | args.Length == 0) {
                    myCore.Run();
                } else {
                    foreach (string runNo in args) {
                        int CallFunctionNumber = 0;
                        bool result = Int32.TryParse(runNo, out CallFunctionNumber);
                        if (result) {
                            Agent.CallNumber callNo = (Agent.CallNumber)Math.Abs(CallFunctionNumber);
                            myCore.Run(callNo);
                        }
                    }
                }
                myCore = null;
            } catch (Exception ex) {
                tpLog.Add("TpAgent-Main", ex);
            } finally {
                
            }
			if (tpLog.HasErrors)
			{
				tpLog.SaveToDisk();
			}
		}
	}


}
